package com.sskj.lib.widget;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomSheetDialog;
import android.view.ViewGroup;
import android.widget.TextView;


import com.sskj.lib.R;
import com.sskj.lib.R2;

import butterknife.BindView;
import butterknife.ButterKnife;

public class SelectPictureDialog extends BottomSheetDialog {

    @BindView(R2.id.select_by_album)
    TextView selectByAlbum;
    @BindView(R2.id.select_by_photo)
    TextView selectByPhoto;
    @BindView(R2.id.cancel)
    TextView cancel;

    private SelectListener mListener;

    public SelectPictureDialog(@NonNull Context context) {
        super(context);
    }

    public SelectPictureDialog(@NonNull Context context, int theme) {
        super(context, theme);
    }

    protected SelectPictureDialog(@NonNull Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.select_picture);
        ButterKnife.bind(this);
        getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT);
        selectByAlbum.setOnClickListener(v -> {
            if (mListener != null) {
                mListener.selectByAlbum();
            }
            dismiss();
        });
        selectByPhoto.setOnClickListener(v -> {
            if (mListener != null) {
                mListener.selectByPhoto();
            }
            dismiss();
        });
        cancel.setOnClickListener(v -> {
            dismiss();
        });
    }

    public void setOnSelectListener(SelectListener listener) {
        this.mListener = listener;
    }

    public interface SelectListener {
        void selectByAlbum();

        void selectByPhoto();
    }

    @Override
    public void show() {
        super.show();

    }
}
